import javax.security.sasl.AuthorizeCallback;

/**
 * Created by zyl on 17-5-17.
 */
public class Book {
    private String name;
    private String author;
    private String editor;
    private Integer date;

    public Book(String name, String author, String editor, int date) {
        this.name = name;
        this.author = author;
        this.editor = editor;
        this.date = date;
    }

    public String getEditor() {
        return editor;
    }

    public void setEditor(String editor) {
        this.editor = editor;
    }


    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }


    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public Integer getDate() {
        return date;
    }

    public void setDate(Integer date) {
        this.date = date;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (name != null ? !name.equals(book.name) : book.name != null) return false;
        if (author != null ? !author.equals(book.author) : book.author != null) return false;
        if (editor != null ? !editor.equals(book.editor) : book.editor != null) return false;
        return date != null ? date.equals(book.date) : book.date == null;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (author != null ? author.hashCode() : 0);
        result = 31 * result + (editor != null ? editor.hashCode() : 0);
        result = 31 * result + (date != null ? date.hashCode() : 0);
        return result;
    }
}

class Bookshelf {
    public static void main(String[] args) {
        Book a = new Book("Math", "Jane", "China", 20000202);
        Book b = new Book("Chinese", "Kate", "China", 20100202);
        Book c = new Book("Physics", "Mike", "England", 19980202);
        Book d = new Book("Chinese", "Kate", "China", 20100202);
        if (a.equals(b)) {
            System.out.println("a equals b");
        }
        if (b.equals(d)) {
            System.out.println("b equals d");
        }
    }
}

